@extends('admin.layouts._menu')
@section('content')
    {{--@include('layouts._message')--}}
    <div class="card">
        <div class="card-body">
            <ul class="nav nav-tabs nav-overflow header-tabs">
                <li class="nav-item">
                    <a href="{{route('admin.slider.index')}}" class="nav-link pb-3 active">
                        幻灯片列表
                    </a>
                </li>
                <li class="nav-item">
                    <a href="{{route('admin.slider.create')}}" class="nav-link pb-3">
                        新增幻灯片
                    </a>
                </li>
            </ul>
        </div>
        <div class="card-body small">
            <table class="table">
                <thead>
                <tr>
                    <th>编号</th>
                    <th>幻灯片描述</th>
                    <th>跳转链接</th>
                    <th>图片</th>
                    <th>创建时间</th>
                    <th></th>
                </tr>
                </thead>
                <tbody>
                @foreach($sliders as $slider)
                    <tr>
                        <td scope="row">{{$slider['id']}}</td>
                        <td>{{$slider['title']}}</td>
                        <td>
                            <a href="{{$slider['url']}}" target="_blank">{{$slider['url']}}</a>
                        </td>
                        <td>
                            <div class="avatar avatar-lg avatar-4by3">
                                <a href="{{$slider['image']}}" target="_blank">
                                    <img src="{{$slider['image']}}" alt="..." class="avatar-img rounded">
                                </a>
                            </div>
                        </td>
                        <td>{{$slider['created_at']}}</td>
                        <td class="text-right">
                            <div class="btn-group btn-group-sm" role="group" aria-label="First group">
                                <a href="{{route('admin.slider.edit',$slider)}}" class="btn btn-light">编辑幻灯片</a>
                                <button type="button" class="btn btn-white" onclick="del({{$slider['id']}})">删除幻灯片</button>
                                <form action="{{route('admin.slider.destroy',$slider)}}" method="post" id="{{$slider['id']}}">
                                    @csrf @method('DELETE')
                                </form>
                            </div>
                        </td>
                    </tr>
            @endforeach
                </tbody>
            </table>
        </div>
    </div>
@endsection
@push('js')
    <script>
        function del(id) {
            if (confirm('确定删除吗？')) {
                $('#'+id).submit();
            }
        }
    </script>
@endpush

